
#ifndef IRIDE_MATH_H_
#define IRIDE_MATH_H_

#include "Types.h"

#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>

namespace Iride
{
	namespace Math
	{
		inline int Abs(int p_A)
		{
			return std::abs(p_A);
		}

		inline double Abs(double p_A)
		{
			return std::abs(p_A);
		}

		inline int Max(Uint p_A, Uint p_B)
		{
			return std::max<Uint>(p_A, p_B);
		}

		inline int Max(int p_A, int p_B)
		{
			return std::max<int>(p_A, p_B);
		}

		inline int Min(int p_A, int p_B)
		{
			return std::min<int>(p_A, p_B);
		}

		inline Real Max(Real p_A, Real p_B)
		{
			return std::max<Real>(p_A, p_B);
		}

		inline int Min(Uint p_A, Uint p_B)
		{
			return std::min<Uint>(p_A, p_B);
		}

		inline Real Min(Real p_A, Real p_B)
		{
			return std::min<Real>(p_A, p_B);
		}

		template<class T>
		inline T MaxVal()
		{
			return std::numeric_limits<T>::max();
		}

		inline Real Clamp(Real value, Real inf, Real sup)
		{
			return std::min<Real>(sup, std::max<Real>(inf, value));
		}

		inline int Clamp(int value, int inf, int sup)
		{
			return std::min<int>(sup, std::max<int>(inf, value));
		}

		inline double Sin(double value)
		{
			return std::sin(value);
		}

		inline double Cos(double value)
		{
			return std::cos(value);
		}

		inline Real RandReal(Real min = 0.0f, Real max = 1.0f)
		{
			return   min + (max - min) * ( (Real)(std::rand() ) / (Real)(RAND_MAX) );
		}

		inline void RandSeed(int seed)
		{
			std::srand(seed);
		}

		const double PI = 3.141592;

		void Lerp(Real start, Real end, int numValues, Real * out);

		void GetLine(int x, int y, int x2, int y2, int * yOut);
	}
}

#endif


